# -*- coding: utf-8 -*-
# 读取文件，按出现顺序去重并覆盖原文件，最后输出原行数与去重后行数
p = '球员数据中文-去重.txt'
with open(p, 'r', encoding='utf-8') as f:
    lines = f.read().splitlines()
total = len(lines)
seen = set()
out = []
for l in lines:
    if l not in seen:
        seen.add(l)
        out.append(l)
with open(p, 'w', encoding='utf-8') as f:
    if out:
        f.write('\n'.join(out) + '\n')
    else:
        f.write('')
print('total_lines=', total)
print('unique_lines=', len(out))
